package com.tebiecloud.base.client.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tebiecloud.base.client.model.entity.BaseApi;
import com.tebiecloud.common.utils.StringUtils;
import lombok.Data;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * IP名单
 * @Author: tebie
 * @Date: 2019-08-08 16:22
 */
@Data
public class IpLimitApi extends BaseApi implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long itemId;

    private Long policyId;

    private String policyName;

    private Integer policyType;

    @JsonIgnore
    private String ipAddress;

    private Set<String> ipAddressSet ;

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
        if(StringUtils.isNotBlank(ipAddress)){
            ipAddressSet =  new HashSet(Arrays.asList(ipAddress.split(";")));
        }
    }

}
